let rec fib_list l valmax =
   let x = (List.nth l 0) + (List.nth l 1) in
   if ( x <= valmax ) then
      fib_list ([x]@l) valmax
   else
      l;;

let rec even_sum l cum =
   match l with
     x::tl -> if ( x mod 2 = 0 ) then
                even_sum tl (cum + x)
              else
                even_sum tl cum 
   | [] -> cum;;

let fl =
   let valmax = 4000000 in
   let l = [2;1] in
      fib_list l valmax
in even_sum fl 0;;

